//////////////////////////////////////////////////////////////////////////////////
//	 Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#include "def.h"
#include "../common/MarkupSTL.h"
#include "routercaps.h"

CRouterCaps		CRouterCaps::m_gCaps;

CRouterCaps::CRouterCaps(void)
{
	Reset();
}

CRouterCaps::~CRouterCaps(void)
{
}

CRouterCaps& CRouterCaps::GetIntstance()
{
	return m_gCaps;
}

void CRouterCaps::Reset()
{
	m_bHasMACFilter			=
	m_bHasPing				=	
	m_bHasPortForward		=
	m_bHasBandwidth			=
	m_bHasConnectionsList	=	
	m_bHasTCPNATSettings	=	
	m_bHasProcKill			=
	m_bHasSyslogConfig		=
	m_bXMLScriptFormat		=
	m_bHasNATUsageInfo		= 
	m_bHasMEMUsageInfo		= 
	m_bHasCPUUsageInfo		= 
	m_bHasRTUsageInfo		= 
	m_bHasKernelMod			=
	m_bHasModem				=
	m_bHasWireless			= false;

	m_strShellName			= "";
	m_strModemName			= "";
	m_strAPName				= "";
}

void CRouterCaps::SetShellCaps(const char* str)
{
	CMarkupSTL	doc;

	if ( doc.SetDoc(str) &&
		 doc.FindElem(SHELL_CAPS_EL) )
	{
		m_strShellName		= doc.GetAttrib( GLOBAL_NAME_ATR )==GLOBAL_ENABLE_VAL;
		m_bHasMACFilter		= doc.GetAttrib( SHELL_MAC_FILTER)==GLOBAL_ENABLE_VAL;
		m_bHasPing			= doc.GetAttrib( SHELL_PING)==GLOBAL_ENABLE_VAL;
		m_bHasPortForward	= doc.GetAttrib( SHELL_PORT_FORWARD)==GLOBAL_ENABLE_VAL;
		m_bHasBandwidth		= doc.GetAttrib( SHELL_BANDWIDTH)==GLOBAL_ENABLE_VAL;
		m_bHasConnectionsList = doc.GetAttrib( SHELL_CONNECTIONS)==GLOBAL_ENABLE_VAL;
		m_bHasTCPNATSettings = doc.GetAttrib( SHELL_TCPNAT_SETTNGS)==GLOBAL_ENABLE_VAL;
		m_bHasProcKill		= doc.GetAttrib( SHELL_PROCKILL)==GLOBAL_ENABLE_VAL;
		m_bHasSyslogConfig	= doc.GetAttrib( SHELL_SYSLOGCONFIG)==GLOBAL_ENABLE_VAL;
		m_bHasKernelMod		= doc.GetAttrib( SHELL_KERNELMOD)==GLOBAL_ENABLE_VAL;
		m_bXMLScriptFormat	= doc.GetAttrib( SHELL_SCRIPT_FORMAT)==SCRIPT_FORMAT_XML_VAL;

		m_bHasNATUsageInfo  = doc.GetAttrib( SHELL_NAT_USAGE)==GLOBAL_ENABLE_VAL;
		m_bHasMEMUsageInfo	= doc.GetAttrib( SHELL_MEM_USAGE)==GLOBAL_ENABLE_VAL;
		m_bHasCPUUsageInfo	= doc.GetAttrib( SHELL_CPU_USAGE)==GLOBAL_ENABLE_VAL;
		m_bHasRTUsageInfo	= doc.GetAttrib( SHELL_RT_USAGE)==GLOBAL_ENABLE_VAL;

	}
}

void CRouterCaps::SetAPCaps(const char* str)
{
	CMarkupSTL	doc;

	if ( doc.SetDoc(str) &&
		doc.FindElem(WIRELESS_CAPS) )
	{
		m_bHasWireless = !doc.GetAttrib( GLOBAL_NAME_ATR).empty();
	}
}

void CRouterCaps::SetModemCaps(const char* str)
{
	CMarkupSTL	doc;

	if ( doc.SetDoc(str) &&
		doc.FindElem(ADSL_CAPS) )
	{
		m_bHasModem = !doc.GetAttrib( GLOBAL_NAME_ATR).empty();
	}
}
